<!-- 修改后的 index.html 页面 -->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>体检评估查询</title>
    <meta charset="UTF-8">
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
        }

        h1 {
            color: #333;
            text-align: center;
        }

        form {
            max-width: 400px;
            margin: 0 auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        label {
            display: block;
            margin-bottom: 5px;
            color: #666;
        }

        input[type="text"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        button[type="submit"] {
            display: block;
            width: 100%;
            padding: 10px;
            background-color: #333;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        div {
            margin-top: 20px;
        }

        h2 {
            color: #333;
        }

        ul {
            list-style-type: none;
            padding: 0;
        }

        li {
            color: #666;
            height: 1px;
        }

        table {
        width: 100%;
        border-collapse: collapse;
    }

    th, td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
    }

    th {
        background-color: #f2f2f2;
    }
    .action-buttons {
            display: flex;
            justify-content: space-around;
    }

    .topform {
        display: flex;
        flex-direction:row;
        justify-content: space-around;
    }
    .t1 {
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 200px;
    }
    .t1 input{
        margin: 1% auto;
        width: 87%;
    }
    .t2{
        width: 250px;
    }
    .t2 input{
        margin: 1% auto;
        width:90%;
    }
    button{
        margin-top: 20px;
    }
    button:hover{
        color: red;
    }

    .t1 form{
        width: 200px;
    }

    </style>
</head>

<body>
<h1>体检评估数据操作</h1>
<div class="topform">
<!--    div-->
    <div class="t1">
        <form action="/searchadmin/Assessment" method="post">
            <label for="assessmentName">请输入体检号进行查询:</label>
            <input type="text" id="assessmentName" name="assessmentName" formaction="assessmentName" placeholder="体检号(例如:健康体检1)" required />
            <button type="submit"><b>查&nbsp;&nbsp;&nbsp;询</b></button>
        </form>
        <form action="/manage_assessments" method="get">
            <button type="submit"><b>显&nbsp;&nbsp;&nbsp;示&nbsp;&nbsp;&nbsp;全&nbsp;&nbsp;&nbsp;部</b></button>
        </form>
    </div>
    <div class="t2">
        <form action="/add/Assessment" method="post">
            <input type="text" name="assessmentName" placeholder="体检号" required />
            <input type="text" name="assessmentResult" placeholder="评估结果" required />
            <input type="text" name="suggestion" placeholder="建议" required />
            <input type="text" name="status" placeholder="状态" required />
            <button type="submit" style="width: 100%"><b>添&nbsp;&nbsp;&nbsp;加</b></button>
        </form>
    </div>
</div>

<table>
    <tr>
        <th>体检号</th>
        <th>评估结果</th>
        <th>建议</th>
        <th>创建时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    <div th:if="${results}">
        <ul>
            <li th:each="result : ${results}">
                <tr>
                    <!--/*@thymesVar id="result" type="com.linfnn.*"*/-->
                    <td th:text="${result.assessmentName}"></td>
                    <td th:text="${result.assessmentResult}"></td>
                    <td th:text="${result.suggestion}"></td>
                    <td th:text="${result.creationTime}"></td>
                    <td th:text="${result.status}"></td>
                    <td class="action-buttons">
                        <!-- 发送请求到后端，这个需要是主键即可 -->
                        <form action="/delete/Assessment" method="post" >
                            <input type="hidden" name="assessmentName" th:value="*{result.assessmentName}"/>
                            <button type="submit">删除</button>
                        </form>
                        <!-- 发送请求到后端，这个需要是主键即可 -->
                        <form action="/updatehtml/Assessment" method="post" >
                            <input type="hidden" name="assessmentName" th:value="*{result.assessmentName}"/>
                            <button type="submit">修改</button>
                        </form>
                    </td>
                </tr>
            </li>
        </ul>
    </div>
</table>
<div th:if="${results == null}">
    <h1>结果为空</h1>
</div>
</body>

</html>
